package cn.wolfcode.enums;

import lombok.Getter;

@Getter
public enum ConsumptionStatusEnum {
    /*枚举需要用的是,隔开*/
    CONSUME("待结算", 0),
    AUDIT("待审核", 1),
    FINISH("归档", 2),
    FAILURE("坏账", 3);

    private Integer value;
    private String name;

    //枚举类的构造器本来就是私有的
    private ConsumptionStatusEnum(String name, Integer value) {
        this.name = name;
        this.value = value;
    }

    public static String findName(Integer value) {
        //获取所有的枚举常量，然后遍历并返回它的name
        ConsumptionStatusEnum[] values = ConsumptionStatusEnum.values();
        //所有的枚举常量
        for (ConsumptionStatusEnum consumptionStatusEnum : values) {
            //判断如果传入的枚举常量值等于某一个枚举常量值，则将其名字返回
            if (consumptionStatusEnum.getValue().equals(value)) {
                return consumptionStatusEnum.getName();
            }
        }
        return null;
    }
}
